package service

import (
	"a-common/myerr"
	"a-payment/domain/entity"
	"sync"
)

var (
	payPaymentServiceTemp *PayPaymentService
	payPaymentServiceOnce sync.Once
)

type PayPaymentService struct{}

func NewPayPaymentService() *PayPaymentService {
	payPaymentServiceOnce.Do(func() {
		payPaymentServiceTemp = &PayPaymentService{}
	})
	return payPaymentServiceTemp
}

// Pay 统一支付接口
func (m *PayPaymentService) Payment(args *entity.PayRecord) (any, error) {
	if args.Vendor == entity.VENDOR_SYS {
		// 系统支付
		if args.Channel == entity.VENDOR_SYS_CARD {
			println("点卡支付")
		} else if args.Channel == entity.VENDOR_SYS_INTEGRAL {
			println("积分支付")
		}
	} else {
		// 第三方支付
		if args.Vendor == entity.VENDOR_ALI {
			// 支付宝
			if args.Channel == entity.VENDOR_ALI_ALIPAY {
				println("支付宝支付")
			}
		} else if args.Vendor == entity.VENDOR_Wx {
			// 微信
			if args.Channel == entity.VENDOR_Wx_WEPAY {
				println("微信支付")
			}
		}
	}
	return nil, myerr.ERR_SYS_ARGS
}

// Query 统一查询接口
func (m *PayPaymentService) Query(args *entity.PayRecord) (any, error) {
	return nil, myerr.ERR_SYS_ARGS
}

// 统一撤销接口
func (m *PayPaymentService) Revoke(args *entity.PayRecord) (any, error) {
	return nil, myerr.ERR_SYS_ARGS
}

// Refund 统一退款接口
func (m *PayPaymentService) Refund(args *entity.PayRecord) (any, error) {
	return nil, myerr.ERR_SYS_ARGS
}

// RefundQuery 统一退款查询接口
func (m *PayPaymentService) RefundQuery(args *entity.PayRecord) (any, error) {
	return nil, myerr.ERR_SYS_ARGS
}
